<!--
 * @Description: 处理设置
 * @Author: lixianggang
 * @Date: 2022-11-17 17:34:12
 * @LastEditors: lixianggang
 * @LastEditTime: 2022-11-23 17:58:46
-->
<template>
    <el-dialog title="开始处理" :visible.sync="showDialog" width="40%">
        <el-form :model="form" :rules="rules" ref="form" label-width="120px">
            <el-form-item label="请输入处理结果" prop="dealResult">
                <el-input v-model="form.dealResult" clearable maxlength="64"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer">
            <el-button @click="cancelCheck">取 消</el-button>
            <el-button type="primary" @click="saveCheck" :loading="saveLoading">确认</el-button>
        </div>
    </el-dialog>
</template>

<script>
import { dealRemind } from "@/api/operate/riskControl"
export default {
    props: {
        visible: {
            type: Boolean,
            default: false
        },
        remindType: {
            type: Number
        },
        currentNoticeId: String
    },
    computed: {
        showDialog: {
            get() {
                return this.visible
            },
            set(val) {
                this.$emit('update:visible', val)
            },
        },
    },
    watch: {
        currentNoticeId(newValue) {
            this.form.noticeId = newValue
        }
    },
    data() {
        return {
            saveLoading: false,
            form: {
                dealResult: "",
                noticeType: this.remindType,
                noticeId: ""
            },
            rules: {
                dealResult: [{ required: true, message: '请输入处理结果', trigger: 'blur' }],
            },
        }
    },
    methods: {
        cancelCheck() {
            this.$refs.form.resetFields();
            this.showDialog = false
        },
        saveCheck() {
            this.$refs.form.validate((valid) => {
                if (valid) {
                    this.handleCheck()
                } else {
                    return false;
                }
            });
        },
        handleCheck() {
            this.saveLoading = true
            dealRemind(this.form)
                .then(res => {
                    this.saveLoading = false
                    if (res.code === 200) {
                        this.showDialog = false
                        this.$message.success(res.msg || "处理成功")
                        this.$refs.form.resetFields();
                        this.$emit("dealwithSuccess")
                    }
                })
                .catch(err => {
                    this.saveLoading = false
                })
        },
    }
}
</script>

<style>

</style>